# $Id: PKGBUILD 166971 2012-09-23 22:22:21Z bisson $
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: lydgate

pkgname=mlocate
pkgver=0.26
pkgrel=1
pkgdesc='Merging locate/updatedb implementation'
url='https://fedorahosted.org/mlocate/'
arch=('i686' 'x86_64')
license=('GPL')
backup=('etc/updatedb.conf'
        'etc/cron.daily/updatedb')
source=("https://fedorahosted.org/releases/m/l/mlocate/mlocate-${pkgver}.tar.xz"
	'updatedb.conf'
	'updatedb.cron')
sha1sums=('c6e6d81b25359c51c545f4b8ba0f3b469227fcbc'
          '0150379149bf9d714bc81332d775fc273e7e3535'
          '8301e6277d27db539af6cf4bc243e8e247bffc2e')

build() {
	cd "${srcdir}/${pkgname}-${pkgver}"

	sed -i '/^groupname /s/mlocate/locate/' Makefile.in
	./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib
	make
}

check() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	make check
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"

	make DESTDIR="${pkgdir}" install

	chgrp 21 "${pkgdir}/usr/bin/locate"
	chmod 2755 "${pkgdir}/usr/bin/locate"
	ln -s locate "${pkgdir}/usr/bin/slocate"

	install -dm755 "${pkgdir}/var/lib"
	install -dm750 -g21 "${pkgdir}/var/lib/locate"
	
	install -Dm644 ../updatedb.conf "${pkgdir}/etc/updatedb.conf"
	install -Dm744 ../updatedb.cron "${pkgdir}/etc/cron.daily/updatedb"
}
